package com.company.引入;

import java.io.FileInputStream;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.Properties;

public class Main {

    public static void main(String[] args) throws IOException, ClassNotFoundException, NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {

        // 1. 读取配置文件
        Properties p = new Properties();
        p.load(new FileInputStream("round100.txt"));
        //获取文件内name属性的值
        String name = "com.company.引入."+p.getProperty("name");
        System.out.println(name);

        // 2. 根据配置创建关卡信息
        Monster m=null;
        /*if("SmallMonster".equals(name))
        {
            m = new SmallMonster();
        }
        else if("BigMonster".equals(name))
        {
            m = new BigMonster();
        }
        else if("BossMonster".equals(name))
        {
            m = new BossMonster();
        }*/

        // 得到怪物类的类对象
        Class c = Class.forName(name);
        //相当于实例化
        m = (Monster)c.getDeclaredConstructor().newInstance();
        // 假设有很多怪物
        m.kill();
    }
}
